

package d0324;

public class Sheep2 implements Cloneable{
    private String name;
    private int age;
    private Person owner;
    public Person getOwner() {
        return owner;
    }

    public void setOwner(Person owner) {
        owner = owner;
    }

    public Sheep2(String name,int age,Person Owner){
        this.name=name;
        this.age=age;
        this.owner=owner;
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public static void main(String[] args) {
        Person o1 = new Person("Own1",22,"Dalian");
        Person o2 = new Person("Own2",23,"Dalian");
        Sheep2 s1 = new Sheep2("Alice",3,o1);
        try {
            Sheep2 duoli = (Sheep2)s1.clone();
            //s1.setOwner(o2);
            System.out.println(s1.getOwner()==duoli.owner);
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
//        Sheep2 s1 = new Sheep2("Alice",3);
//        try {
//            Sheep2 duoli = (Sheep2) s1.clone();
//            s1.setName("Brown");
//            System.out.println("s1==duoli:"+(s1==duoli));
//            System.out.println(duoli.name+"\t"+duoli.age);
//            System.out.println(s1.name==duoli.name);
//            System.out.println(s1.age==duoli.age);
//        } catch (CloneNotSupportedException e) {
//            e.printStackTrace();
//        }

    }
}